package com.yang.cloud.controller;

import com.yang.cloud.entity.User;
import com.yang.cloud.feign.UserFeignClient;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cloud.client.ServiceInstance;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @author yang.yang@karakal.com.cn
 * @version V1.0
 * @Description:
 * @date 2017-11-13 18:00
 */
@RestController
public class UserController {

    @Autowired
    private UserFeignClient userFeignClient;

    @GetMapping("/feign/user/{id}")
    public User findById(@PathVariable Long id) {
        return this.userFeignClient.findById(id);
    }

    @GetMapping("/feign/user")
    public List<User> getUser() {
        return this.userFeignClient.getUser();
    }

    @PostMapping("/feign/user")
    public User postUser(@RequestBody User user) {
        return this.userFeignClient.postUser(user);
    }

    @GetMapping("/feign/eureka-instance")
    public String getInstance() {
        return this.userFeignClient.eurekaInstance();
    }

    @GetMapping("/feign/instance-info")
    public ServiceInstance getInfo() {
        return this.userFeignClient.instanceInfo();
    }
}
